package com.example.springbootwebserviceproxy.pool;

import cn.hutool.core.util.StrUtil;
import com.example.springbootwebserviceproxy.model.WebServiceBeanDefinition;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * DefaultSOAPServiceFactoryImpl.
 *
 * @author <a href='mailto:likeguo@apache.com'> likeguo </a>
 */
@Component
@RequiredArgsConstructor
public class DefaultSOAPServiceFactoryImpl implements SOAPServiceFactory {
    
    private final SOAPServicePool soapServicePool;
    
    @Override
    public WebServiceBeanDefinition getServiceByName(final String name) {
        if (StrUtil.startWith(name, '/')) {
            return soapServicePool.getServiceByName(StrUtil.removePrefix(name, "/"));
        }
        return soapServicePool.getServiceByName(name);
    }
}
